package com.learning.spring.cloud.eureka;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName: EurekaClientApplication
 * @Description:
 * @author: limingxing
 * @Date: 2020-07-10 14:06
 */
@EnableDiscoveryClient
@SpringBootApplication
public class EurekaClientApplication {

    public static void main(String[] args) {
        new SpringApplicationBuilder( EurekaClientApplication.class)
                .web(true).run(args);
    }

    @RestController
    public class DcController {

        @Autowired
        DiscoveryClient discoveryClient;

        @GetMapping("/dc")
        public String dc() throws InterruptedException {
//            Thread.sleep(5000);
            String services = "Services: " + discoveryClient.getServices();
            System.out.println(services);
            return services;
        }

    }
}